﻿using HotelCardClient.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HotelCardClient.Views
{
    /// <summary>
    /// Interaction logic for Home.xaml
    /// </summary>
    public partial class Home : Window
    {
        HomeViewModel _model = new HomeViewModel();
        public Home()
        {
            InitializeComponent();

            DataContext = _model;
        }

        private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            // ... Get DatePicker reference.
            var picker = sender as DatePicker;
            var name = picker.Name;

            // ... Get nullable DateTime from SelectedDate.
            DateTime? date = picker.SelectedDate;
            if (date != null)
            {
                switch(name)
                {
                    case "checkin":
                        _model.CheckInDate = date;
                        break;
                    case "checkout":
                        _model.CheckOutDate = date;
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
